define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'log/money_log/index'
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                search:false,
                columns: [
                    [
                        {field: 'id', title: 'ID',sortable:true},
                        {field: 'desc', title: __('Desc'),sortable:false},
                        {field: 'user_name', title: __('User name'),searchable:false},
                        {field: 'house_property_name', title: __('House property name'),searchable:false},
                        {field: 'user_id', title: __('User ID')},
                        {field: 'current_money', title: __('Current money'),searchable:false},
                        {field: 'money', title: __('Money'),searchable:false},
                        {field: 'change_type', title: __('Change type'),formatter:function(value,row,index){
                            value = value + '';
                            switch (value){
                                case '0':
                                    return __('House property');
                                case '1':
                                    return __('Withdrawal fail');
                                case '2':
                                    return __('Withdrawal success');
                            }
                        },searchList: {'0': __('House property'), '1': __('Withdrawal fail'),'2': __('Withdrawal success')}, style: 'min-width:100px;'
                        },
                        {field: 'money_type', title: __('Money type'),formatter:function(value,row,index){
                            value = value + '';
                            switch (value){
                                case '0':
                                    return __('Water charge');
                                case '1':
                                    return __('Property charge');
                                case '2':
                                    return __('Withdrawal charge');
                            }
                        },searchList: {'0': __('Water charge'), '1': __('Property charge')}, '2':__('Withdrawal charge'), style: 'min-width:100px;'
                        },
                        {field: 'in_out_type', title: __('In out type'),formatter:function(value,row,index){
                            value = value + '';
                            switch (value){
                                case '0':
                                    return __('In');
                                case '1':
                                    return __('Out');
                                default:
                                    return __('In');
                            }
                        },searchList: {'0': __('In'), '1': __('Out')}, style: 'min-width:100px;'
                        },
                        {field: 'create_time', title: __('Create time'),
                            formatter: Table.api.formatter.datetime, operate: 'BETWEEN',
                            type: 'datetime', addclass: 'datetimepicker',
                            data: 'data-date-format="YYYY-MM-DD"'
                        }
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        }
    };
    return Controller;
});